var fs = require('fs');
var zip = require('node-native-zip');

var archive = new zip();

var filesArr = [];
fs.readdirSync('../midis3-admin/dist/', (err, files) => {
  if (err) {
    console.error(err);
  }
  files.forEach(file => {
    console.log('file:', file)
    filesArr.push({
      name: file,
      path: file
    });
  });

  archive.addFiles(filesArr, (err) => {
    return console.error('err while adding files:', err);
    var buf = archive.toBuffer();
    fs.writeFile("./dist/zhishen.zip", buf, function () {
      console.log("Finished");
    });
  })
})

var fs = require('fs');

var path = '../midis3-admin/dist/';

function explorer(path) {
  fs.readdir(path, function (err, files) {
    if (err) {
      console.log('error:\n' + err);
      return;
    }

    files.forEach(function (file) {
      fs.stat(path + "\\" + file, function (err, stat) {
        if (err) {
          console.log(err);
          return;
        }

        if (stat.isDirectory()) {
          console.log(path + "\\" + file + "\\");
          explorer(path + "\\" + file);
        } else {
          console.log(path + "\\" + file);
        }

      });
    });

  });
}

explorer(path);
